import router from 'umi/router';

import React from 'react';
import { connect } from 'dva';
import Link from 'umi/link'
import { Table, Button } from 'antd';

const linePath = '/AccountInvoice/Invoice';
const formPath = '/AccountInvoice/InvoiceForm';

@connect(({ accountInvoice }) => ({ accountInvoice }))
class List extends React.Component {
  state = {
  }

  treeview = [
      {
        title: '',
        dataIndex: '_',
        render: (_, { id }) => {
          return <Link to={`${linePath}?id=${id}`}>查看</Link>;
        },
      },
      { title: '类型', dataIndex: 'type', },
      { title: '状态', dataIndex: 'state', },
      { title: '日期', dataIndex: 'date', },
      { title: '账簿', dataIndex: 'journal_id.name', },
      { title: '业务伙伴', dataIndex: 'partner_id.name', },
      { title: '总金额', dataIndex: 'amount_total', },
      { title: '到期日期', dataIndex: 'date_due', },
      { title: '科目', dataIndex: 'account_id.name', },
//      { title: '凭证', dataIndex: 'move_id.name', },
      { title: '凭证号', dataIndex: 'number', },
//      { title: '名称', dataIndex: 'name', },
//      { title: '明细', dataIndex: 'invoice_line_ids', },
//      { title: '税明细', dataIndex: 'tax_line_ids', },
  ]

  async componentDidMount() {
    const { dispatch } = this.props;
    dispatch({
      type: 'accountInvoice/search',
      payload: {domain:[], },

    });
  }


  goto_createForm() {
      router.push(formPath);
  }


  render() {
    const { accountInvoice: { recordsList } } = this.props;

    return (
      <div>

        <Button onClick={()=>this.goto_createForm()}>新建</Button>
        <Table columns={this.treeview} dataSource={recordsList} rowKey="id" />


      </div>
    );
  }
}

export default List;





